package cn.dubito.springcloud.cfgbean;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RetryRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * 配置类
 * @author liliang
 * @description:
 * @date 2018/5/20.
 */
@Configuration
public class ConfigBean {


    /**
     * 注册一个 RestTemplate bean
     * Ribbon 负载均衡 LoadBalanced
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    /**
     * 算法选择  默认是轮询
     * @return
     */
    @Bean
    public IRule rule() {
        return new RetryRule();
    }
}
